package com.xy.biz.base.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.base.domain.bo.SupplierBO;
import com.xy.biz.base.domain.po.SupplierPO;
import com.xy.biz.base.domain.query.SupplierQuery;
import com.xy.biz.base.domain.resp.GetSupplierResponse;
import com.xy.biz.base.domain.req.SaveSupplierRequest;
import com.xy.biz.base.domain.req.ListSupplierRequest;

/**
 * 
 * 
 * @author zgy
 * @date 2021-9-22
 */
public class SupplierConverter {
	
	public static SupplierPO toPO(SupplierBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new SupplierPO(), true);
	}
	
	public static List<SupplierPO> toPO(Collection<SupplierBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new SupplierPO(), true);
	}
	
	public static SupplierBO fromPO(SupplierPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new SupplierBO());
	}
	
	public static List<SupplierBO> fromPO(Collection<SupplierPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new SupplierBO());
	}
	
	public static SupplierBO toBO(SaveSupplierRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new SupplierBO(), true);
	}
	
	public static List<SupplierBO> toBO(Collection<SaveSupplierRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new SupplierBO(), true);
	}
	
	public static GetSupplierResponse toResponse(SupplierBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetSupplierResponse());
	}
	
	public static List<GetSupplierResponse> toResponse(Collection<SupplierBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetSupplierResponse());
	}
	
	public static SupplierQuery toQuery(ListSupplierRequest source) {
		if(null == source) {
			return null;
		}
		SupplierQuery target = new SupplierQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
